package cn.fairy.controller;

import cn.fairy.dto.ProductDto;
import cn.fairy.service.IProductService;
import cn.fairy.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProductController {
    @Autowired
    private IProductService productService;

    @PostMapping ("/product/add")
    public AjaxResult add(@RequestBody ProductDto productDto){
        try{
            productService.add(productDto);
            return new AjaxResult();
        }catch (Exception e){
            e.printStackTrace();
            return new AjaxResult().setSuccess(false).setMessage("降级");
        }


    }

}
